import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    topListIds: [],
    nextId: '' // 下一曲
  },
  mutations: {
    INIT_TOPLISTIDS(state, payload) {
      state.topListIds = payload
    },
    NEXT_ID(state, payload) {
      for(var i=0;i < state.topListIds.length;i++) {
        if(state.topListIds[i].id == payload) {
          if( state.topListIds[state.topListIds.length - 1].id != payload ) {
            state.nextId = state.topListIds[i + 1].id
          } else {
            state.nextId = state.topListIds[0].id
          }
        }
      }
    }
  }
})